package com.example.helloworld;

import android.app.Activity;
import android.os.Bundle;
import android.view.Menu;
import android.widget.ListView;
import cfg.Flickr;

import com.gmail.yuyang226.flickr.people.User;
import com.gmail.yuyang226.flickrj.sample.android.tasks.LoadPhotostreamTask;

public class HomeActivity extends Activity {

	// private TextView nameTextField;
	// private TextView surnameTextField;
	private ListView photosStreamList;

	private User user;

	@Override
	public void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.activity_home);

		// this.nameTextField = (TextView)
		// this.findViewById(R.id.nameTextField);
		// this.surnameTextField = (TextView)
		// this.findViewById(R.id.surnameTextField);
		this.photosStreamList = (ListView) this
				.findViewById(R.id.photosStreamList);

		drawUser();
		drawList();
	}

	@Override
	public boolean onCreateOptionsMenu(Menu menu) {
		getMenuInflater().inflate(R.menu.activity_home, menu);
		return true;
	}

	private void drawUser() {
		user = Flickr.OAUTH_SESSION.getUser();

		// nameTextField.setText(user.getRealName());
		// surnameTextField.setText(user.getUsername());
	}

	private void drawList() {
		// new LoadUserTask(this, userIcon).execute(oauth);
		new LoadPhotostreamTask(this, photosStreamList)
				.execute(Flickr.OAUTH_SESSION);
	}
}
